package org.shijiagen.category.controller;

import lombok.RequiredArgsConstructor;
import org.shijiagen.category.service.CategoryService;
import org.shijiagen.param.PageParam;
import org.shijiagen.pojo.Category;
import org.shijiagen.utils.R;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("category")
@RequiredArgsConstructor
public class CategoryAdminController {

    public final CategoryService categoryService;

    @PostMapping("admin/list")
    public R listPage(@RequestBody PageParam param){
        return categoryService.listPage(param);
    }

    @PostMapping("admin/save")
    public R save(@RequestBody Category category){
        return categoryService.save(category);
    }

    @PostMapping("admin/remove")
    public R remove(@RequestBody Integer categoryId){
        return categoryService.remove(categoryId);
    }

    @PostMapping("admin/update")
    public R update(@RequestBody Category category){
        return categoryService.update(category);
    }
}
